﻿using System.IO;
using System.Runtime.Serialization;
using System.Text;

namespace Mvc.XForms.Tests {
	public static class WcfSerializationHelper {
		public static string Serialize<T>(T obj) {
			var ser = new DataContractSerializer(typeof(T));

			string text;
			using (var stream = new MemoryStream()) {
				ser.WriteObject(stream, obj);
				text = Encoding.UTF8.GetString(stream.GetBuffer());
			}

			return text;
		}
	}
}